function validateName() {
    var name = document.getElementById('name');
    var nameRegex = /^[a-zA-Z\-' ]{3,35}$/;
    name.className = nameRegex.test(name.value) ? "valid" : "invalid";
}

function validateEmail() {
    var email = document.getElementById('email');

    email.className = email.value.length < 3 ? "invalid" : "valid";
}

function validatePassword() {
    var password = document.getElementById('password');

    password.className = password.value.length < 6 ? "invalid" : "valid";
}

function compareEmail() {
    var email = document.getElementById('email');
    var confirmEmail = document.getElementById('confirmEmail');

    if (email.value !== confirmEmail.value || email.value == "") {
        email.className = "invalid";
        confirmEmail.className = "invalid";
    }
    else {
        email.className = "valid";
        confirmEmail.className = "valid";
    }
}

function comparePassword() {
    var password = document.getElementById('password');
    var confirmedPassword = document.getElementById('confirmPassword');

    if (password.value !== confirmedPassword.value || password.value.length < 6) {
        password.className = "invalid";
        confirmedPassword.className = "invalid";
    }
    else {
        password.className = "valid";
        confirmedPassword.className = "valid";
    }
}

function notEmpty(elementName) {
    var element = document.getElementById(elementName);

    if (element.value.length < 1) {
        element.className = "invalid";
    }
    else {
        element.className = "valid";
    }
}

function clearMessage(elementName, delay) {

    var element = document.getElementById(elementName);

    setTimeout(function () {

        element.style.display = 'none';

    }, delay);
}